package factories

import (
	"fmt"
	"github.com/brianvoe/gofakeit/v6"
	"github.com/goravel/framework/support/carbon"
)

type DeviceFactory struct {
}

// Definition Define the model's default state.
func (f *DeviceFactory) Definition() map[string]any {
	time := gofakeit.FutureDate()

	carbonDateTime := carbon.FromStdTime(time)
	//减去1天
	carbonDateTime = carbonDateTime.SubDays(1)
	//var coordinates CoordRes
	//coordinates.Type = "Point"
	////中国31.279555,107.388487 31.116761,107.558129
	//minLatitude := float64(31.0)   // 达州市最南端
	//maxLatitude := float64(31.5)   // 达州市最北端
	//minLongitude := float64(106.0) // 达州市最西端
	//maxLongitude := float64(108.0) // 达州市最东端
	//
	//Longitude, _ := gofakeit.LongitudeInRange(minLongitude, maxLongitude)
	//Latitude, _ := gofakeit.LatitudeInRange(minLatitude, maxLatitude)
	//coordinates.Coordinates = []float64{
	//	Longitude,
	//	Latitude,
	//}

	address := fmt.Sprintf("%s,%s", "达州市", gofakeit.Address().Address)

	board_model := gofakeit.UUID()
	code := gofakeit.UUID()
	name := gofakeit.FirstName()
	online_at := carbon.NewDateTime(carbonDateTime)
	location_at := carbon.NewDateTime(carbonDateTime)
	tower_code := gofakeit.UUID()
	serial_number := fmt.Sprintf("%d", gofakeit.Number(1000, 9999))
	battery_status := gofakeit.RandomString([]string{"1", "2"})
	//转化为carbon.DateTime
	//fmt.Println(board_model, code, name, online_at, location_at, battery_status, tower_code, serial_number)
	return map[string]any{
		"UserID":        1,
		"BoardModel":    board_model,
		"code":          code,
		"name":          name,
		"OnlineAt":      online_at,
		"LocationAt":    location_at,
		"BatteryStatus": battery_status,
		"spec":          "MT33231",
		"TowerCode":     tower_code,
		"SerialNumber":  serial_number,
		"Address":       address,
	}
}
